#pragma once
#include "../World/World Module.h"
#include "../User Interface/Gui_Handler.h"
#include "../World/Entity/Entity.h"

#include "../Engine/Input.h"
#include "../Engine/Networking.h"
#include <ctime>

#ifndef ENGINE
class Engine;
#endif
class Networking;


class GameHandler
{
private:

	//===HANDLERS
#define GUI		GUI_Handler::get()
	e_GameState			m_eGameState;
	ByteBuffer			m_bbWorldData;

	int m_iNumPlayers;
	int m_iPlayerIndex;
	bool m_bWorldInitialized;
	bool musicOn;
	void InitGameWorld();
	void InitPreloaded();

	void handleServerMessages();
	
public:
	Networking			m_network;
	bool autoLootWorldBlocks;

	GameHandler();
	void Init();
	int Update();
	bool VerifyWorld();
	void ReloadWorld();
	void HandleWorldInput();
	void HandleMenuInput();
	void Release();

	bool m_bNeedToSendData;
	bool m_bJoinedMultiplayer;

	/** Accessors */
	int	   getNumPlayers() { return m_iNumPlayers; }
	double getAngleToScreen();
	double getAngleBetweenPoints(Vector3D me, Vector3D them);
	int	   getState() { return m_eGameState; }
	double distanceToClick();

	void ReloadState();
};


#include "Engine/Engine.h"